﻿using System.Globalization;
using System.Net.Http;
using CkSoftware.GroupMe.Sdk.Core;
using CkSoftware.GroupMe.Sdk.Core.Dao;
using CkSoftware.GroupMe.Sdk.Messaging.Dao;

namespace CkSoftware.GroupMe.Sdk.Messaging.Commands
{
	/// <summary>
	/// Group messages index command (GroupMe documentation: <see href="https://dev.groupme.com/docs/v3#messages_index" />).
	/// </summary>
	public class GroupMessagesIndexCommand : IWebApiCommand<GroupMeApiResponse<MessagesIndexData>>
	{
		private const string CommandNameFormat = "groups/{0}/messages";
		private readonly GroupMessagesIndexParameters _parameters;

		/// <summary>
		/// Instantiates a new <see cref="GroupMessagesIndexCommand" /> with the given parameters.
		/// </summary>
		/// <param name="parameters">The <see cref="GroupMessagesIndexParameters"/> to use.</param>
		public GroupMessagesIndexCommand(GroupMessagesIndexParameters parameters)
		{
			_parameters = parameters;
		}

		/// <summary>
		/// Defines if the command is executed once.
		/// </summary>
		public bool CommandExecuted { get; set; }

		/// <summary>
		/// The name of the command to be executed.
		/// </summary>
		public string CommandName
		{
			get { return string.Format(CultureInfo.CurrentCulture, CommandNameFormat, _parameters.GroupId); }
		}

		/// <summary>
		/// The http method to execute this command.
		/// </summary>
		public HttpMethod HttpMethod
		{
			get { return HttpMethod.Get; }
		}

		/// <summary>
		/// The parameters which should be used on command execution.
		/// </summary>
		public IWebApiCommandParameters Parameters
		{
			get { return _parameters; }
		}
	}
}